﻿namespace wToggle.Platform
{
    using System;

    using Windows.UI.Xaml.Controls;

    using wToggle.Platform.Interfaces;

    using XPlatUtils;

    public static class Analytics
    {
        public static void ReportException(Exception ex, bool isFatal = false)
        {
            var analytics = ServiceContainer.TryResolve<IAnalytics>();

            if (analytics == null)
            {
                return;
            }

            analytics.ReportException(ex);
        }

        public static void ReportPageVisit(Page page)
        {
            var analytics = ServiceContainer.TryResolve<IAnalytics>();

            if (analytics == null)
            {
                return;
            }
            
            analytics.ReportPageVisit(page);
        }
        public static void ReportEvent(EventCategory category, EventAction action, string label)
        {
            var analytics = ServiceContainer.TryResolve<IAnalytics>();

            if (analytics == null)
            {
                return;
            }

            analytics.ReportEvent(category, action, label);
        }

        public static void Dispatch()
        {
            var analytics = ServiceContainer.TryResolve<IAnalytics>();

            if (analytics == null)
            {
                return;
            }

            analytics.Dispatch();
        }
    }
}